package com.mes.service.cb;

import com.mes.dao.cb.WarehouRedMapper;
import com.mes.entity.cb.Materiel;
import com.mes.entity.cb.Pages;
import com.mes.entity.cb.WarehRerdMx;
import com.mes.entity.cb.WarehouRed;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

import java.util.List;

/**
 * @ClassName: WarehouRedService
 * @Description: 入库记录
 * @Author cb
 * @Date 2018年4月10日15:58:16
 * @version 1.0
 */
@Service
@Transactional
public class WarehouRedServiceImpl implements WarehouRedService {
    @Resource
    private WarehouRedMapper warehouRedMapper;

    @Override
    public List<WarehouRed> ware_list(Pages pages) {
        return warehouRedMapper.ware_list(pages);
    }


    @Override
    public int getTotal(Pages pages) {
        return warehouRedMapper.getTotal(pages);
    }

    @Override
    public List<WarehRerdMx> wareMX_list(Pages pages) {
        return warehouRedMapper.wareMX_list(pages);
    }

    @Override
    public int getTotalMx(Pages pages) {
        return warehouRedMapper.getTotalMx(pages);
    }

    @Override
    public Materiel storck_ByCode(String code) {
        return warehouRedMapper.storck_ByCode(code);
    }

    @Override
    public long ware_insert(WarehouRed warehouRed) {
        return warehouRedMapper.ware_insert(warehouRed);
    }

    @Override
    public Integer wareMX_insert(List<WarehRerdMx> warehRerdMxes) {


       
    	Integer integer = 0;
        
        for (WarehRerdMx warehRerdMx : warehRerdMxes) {
        	integer = warehouRedMapper.maStock_insert(warehRerdMx);
		}

        if (integer > 0) {
            return warehouRedMapper.wareMX_insert(warehRerdMxes);
        }

        return integer;
    }


	@Override
	public void updateBymaRuKu(Long prid) {
		warehouRedMapper.updateBymaRuKu(prid);
		
	}
}
